package com.yanqu.road.server.cmd.vehicle;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.vehicle.VehicleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleModule;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleSoulModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_VEHICLE_SOUL_RESET, desc = "座骑兽魂重置")
public class VehicleSoulResetCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        VehicleProto.VehicleResetReqMsg reqMsg = VehicleProto.VehicleResetReqMsg.parseFrom(packet.getBytes());
        String vehicleUid = reqMsg.getVehicleUid();

        ret = player.getModule(VehicleSoulModule.class).soulReset(vehicleUid);
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            VehicleProto.VehicleResetRespMsg.Builder respMsg = VehicleProto.VehicleResetRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.S_VEHICLE_SOUL_RESET%20000, respMsg);
        }
    }
}
